package poc;

import java.net.UnknownHostException;

import com.mongodb.DB;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;

public class MongoDb{

    private static MongoDb instance;

    private DB db;
    
    private MongoDb(String uri) {
        MongoClient mongoClient;
        try {
//            PropertiesUtil pl = new PropertiesUtil("classpath:keter-mongo.properties");
        	MongoClientURI mcu = new MongoClientURI(uri);
        	mongoClient = new MongoClient(mcu);
            db = mongoClient.getDB(mcu.getDatabase());
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }

    public static MongoDb getInstance(String uri) {
        if (instance == null) {
            instance = new MongoDb(uri);
        }
        return instance;
    }

    public DB getDb() {
        return this.db;
    }
}